<template>
  <div id="contsainer"></div>
</template>
<script>
export default {
  data() {
    return {
      viewer: null
    }
  },
  mounted() {
    this.initCesium()
    this.addEllipsoid(this.viewer)
  },
  methods: {
    initCesium() {
      this.viewer = new Cesium.Viewer('contsainer', {
        animation: false,
        baseLayerPicker: false,
        fullscreenButton: false,
        geocoder: false,
        homeButton: false,
        infoBox: false,
        sceneModePicker: false,
        navigationHelpButton: false,
        scene3DOnly: true,
        timeline: false,
        selectionIndicator: false, //是否显示选取指示器组件
        shouldAnimate: false, //自动播放动画控件
        shadows: true, //是否显示光照投射的阴影
        terrainShadows: Cesium.ShadowMode.RECEIVE_ONLY, //地质接收阴影
        sceneMode: Cesium.SceneMode.SCENE3D
      })
      this.viewer._cesiumWidget._creditContainer.style.display = 'none' //	去除版权信息
    },
    addEllipsoid(viewer) {
      // 怎么操作椭圆 你知道吗
      viewer.entities.add({
        name: 'Blue sphere',
        position: Cesium.Cartesian3.fromDegrees(-114.0, 40.0, 300000.0),
        ellipsoid: {
          radii: new Cesium.Cartesian3(200000.0, 100000.0, 300000.0), //用于指定椭球的半径，三个方向半径不相等就是椭球体
          material: Cesium.Color.BLUE
        }
      })

      viewer.entities.add({
        name: 'Red sphere',
        position: Cesium.Cartesian3.fromDegrees(-107.0, 40.0, 300000.0),
        ellipsoid: {
          radii: new Cesium.Cartesian3(300000.0, 300000.0, 300000.0), //用于指定椭球的半径,三个方向半径相等就是球形
          material: Cesium.Color.RED.withAlpha(0.9),
          innerRadii: new Cesium.Cartesian3(200000.0, 200000.0, 200000.0) //球体的内半径，也就是挖掉内球
        }
      })

      viewer.entities.add({
        name: 'Yellow ellipsoid',
        position: Cesium.Cartesian3.fromDegrees(-100.0, 40.0, 300000.0),
        ellipsoid: {
          radii: new Cesium.Cartesian3(200000.0, 200000.0, 300000.0),
          fill: false,
          outline: true,
          outlineColor: Cesium.Color.YELLOW,
          slicePartitions: 64, //指定径向切片数量
          stackPartitions: 64, //指定堆栈数
          subdivisions: 1024 //指定每个轮廓环的样本数，确定曲率的粒度
        }
      })
    }
  }
}
</script>
<style scoped>
#contsainer {
  height: 100%;
  width: 100%;
  background-color: red;
}
</style>
